   <?php
session_start();
//include('header.php');
require_once('classes/class.jira.php');
$_SESSION['first_log'] = 1;
include('config.php');
ini_set('display_errors', 'Off');
unset($_SESSION['first_log']);
if(isset($_POST["Jusername"]) && isset($_POST["Jpass"]))    
    {
	$_SESSION["Juname"]=$_POST["Jusername"];
	$_SESSION["Jpass"]=$_POST["Jpass"];
	$_SESSION['jiraUserFullName'] = '';
    
    
            
		$config->username= $_POST["Jusername"];
		$config->password= $_POST["Jpass"];
		$config->port= "";
		$config->host= $host;
		$query = $_POST["Jusername"];
		
		$queryIssue = new Jira($config);
		$array=$queryIssue->queryUserGroup($query);
		$response = json_decode($array->responseBody);
		$user="a";
		for($i=0;$i<count($response->groups->items);$i++){
			if($response->groups->items[$i]->name == $authgroup){
                            $user=$_POST["Jusername"];
                            $_SESSION['jiraUserFullName'] = $response->displayName;
			}
		}
		if($user=="a"){
			echo "<script>document.getElementById(\"error\").innerHTML = \"Invalid Username or Password\";
                            document.getElementById(\"Jusername\").style.backgroundColor = \"#FDBEBE\";
                            document.getElementById(\"Jpass\").style.backgroundColor = \"#FDBEBE\";
                            </script>";
                      //  header('Location:index.php');
		 }
		else{
			//echo '<meta http-equiv="refresh" content="0.1;url=home.php">';
                    $_SESSION['first_log'] = 1;
                 // header('Location:home.php');
                    echo '<script>window.open("reports/reportdash.php","_self")</script>';
           
		}
    }
?>


<html style="background-color: #FFFFFF">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mailbox checker</title>
<!--<link href="css/demo.css" rel="stylesheet" type="text/css" />-->
<link rel="stylesheet" href="css/header_1.css" type="text/css" media="all">           
<link rel="stylesheet" href="css/layout_1.css" type="text/css" media="all">
 <link rel="stylesheet" href="css/header_1.css" type="text/css" media="all">           
        <link rel="stylesheet" href="css/layout_1.css" type="text/css" media="all">
        <link href="css/kendo.common.min.css" rel="stylesheet">   
        <link href="css/kendo.default.min.css" rel="stylesheet">
        <link href="css/examples-offline.css" rel="stylesheet">
        <link href="css/kendo.rtl.min.css" rel="stylesheet">
        <script src="reports/js/jquery.min.js"></script>
<!--<div class="login">
	<div class="details">
			<form name="form" action="index.php" method="post">
			<h2 class="loginhead">JIRA LOGIN</h2>
			User Name:<br>
			<input type="text" class="field" name="Jusername"><br><br>
			Password:<br>
			<input type="password" class="field" name="Jpass"><br><br>
			<input type="submit" value="Login" name="login">
			</form>
	</div>
</div>-->
<script>
//$(document).ready(function(){
////    $('#Jusername').change(function (){       
////        $("#empUser").text('');
////        console.log('r');
////        document.getElementById("Jusername").style.backgroundColor = "#FFFFFF";
////    });
//    
//     $('#Jpass').change(function (){       
//        document.getElementById("empPass").innerHTML = "";
//        document.getElementById("Jpass").style.backgroundColor = "#FFFFFF";
//    });
//                
//});
    function validateForm(){
    var userName = document.forms["myForm"]["Jusername"].value;
    var password =document.forms["myForm"]["Jpass"].value;
 
    if (userName.length ===0) {        
        document.getElementById("empUser").innerHTML = "Username cannot be empty";
         document.getElementById("Jusername").style.backgroundColor = "#FDBEBE";
        return false;
    }     
    if (password.length ===0) {
        document.getElementById("empPass").innerHTML = "Password cannot be empty";
        document.getElementById("Jpass").style.backgroundColor = "#FDBEBE";
        return false;
    }
 
    return true;
}


</script>

<body class="sonata-bc" style="background-color: #FFFFFF">
    <div class="navbar navbar-fixed-top log" style="float: left" >
    <div class="loginside">
            <div class="container-fluid header-bar-container headerDiv" style="">
                <div class="header-bar-top">
                    <a class="brand">
                        <img src="images/logo_white.png" alt="JiraPortal" style="height: 40px;margin: 0;  padding: 11px 24px 20px 1px; vertical-align: middle;font-size: 20px;">
                        Recruitment Application      
                    </a>
                </div>
                
            </div>
     
        <div style="height: 220px; float: left;">
             
<!--                            <form name="myForm" action="index.php" method="post" onsubmit="return validate()">-->
                            <form name="myForm" action="index.php" method="post" onsubmit="return validateForm()">
                            <h2 class="loginhead">JIRA LOGIN</h2>
                            <div id="empty"><h1 id="error" style="color: #FF0000; font-size: 13px;margin: 0 35px; line-height: 10px;"></h1></div>
                            <div><h4 style="padding: 3px 33px 0;color: #3D3D3D; font-weight: normal;">User Name </h4></div>
                            <div><input type="text" id="Jusername" name="Jusername" placeholder="Username" style="font-size: 16px; height: 40px; margin: 0 32px;
                                width: 360px;"></div>
                            <div ><p id="empUser" style="color: #FF0000; font-size: 15px;margin: 5px 35px;"></p></div>
                            <div><h4 style="padding: 3px 33px 0;color: #3D3D3D; font-weight: normal;">Password:</h4></div>
                            <div><input type="password" id='Jpass' name="Jpass" placeholder="Password"style="font-size: 16px; height: 40px; margin: 0 32px;
                                    width: 360px;"></div>
                            <div ><p id="empPass" style="color: #FF0000; font-size: 15px;margin: 5px 35px;"></p></div>
                            <div> <input type="submit" value="Login" name="login" id="login" class="k-button"  style="float: right;
                                    font-family: inherit;font-size: 15px; line-height: 1.66em; margin: 2px 28px; padding: 12px 7px;text-align: center;text-decoration: none;width: 100px;"                                       >
                                </div>     
                            </form>

<!--<div style="float: right;position: relative; right: -22px; top: -17px;"><input class="outlin outimg" id="googlelogin" type="image" src="images/google.png"/></div>-->
              
        </div>
        <div>
            
        </div>
        

        </div>
    </div>

    <style>
        .output{
            width: 100px;
        }
        .outlin:hover{
          outline: 1px solid #CAC3C0;
        }
        label {
           display: block;
    float: none;
    margin: 18px 17px 12px;
    padding: 0;
    text-align: left;
    width: auto;
        }
        .log{
            width: 420px;
            height: 377px;
            margin:10% 37%; 
            border: 1px solid #F58220;
            border-radius: 20px 20px 20px 20px;
            /*box-shadow: 2px 2px 8px #404040;*/
            
        }
        
        .loginside{
            background-color: white;
             border-radius: 20px 20px 20px 20px;
             height: inherit;
        }
        .headerDiv{
            height: 60px;border-radius: 14px 14px 0 0;
        }
    </style>
    </body>
    
 